package com.usian.goodstype.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.usian.goodstype.bean.Goodstype;
import com.usian.goodstype.service.GoodstypeService;
import com.usian.supplier.bean.Supplier;
import com.usian.supplier.service.SupplierService;

@Controller
@RequestMapping("/Goodstype")
/**
 * @author li
 * 	控制层
 * @version  0.0.1
 * */
public class GoodstypeAction {
	@Autowired
	private GoodstypeService goodstypeService;
	@Autowired
	private SupplierService supplierService;
	
	@RequestMapping("/findgoodstype")
	@ResponseBody
	public List<Goodstype> findgoodstype(Goodstype goodstype){
		System.out.println(goodstype);
		List<Goodstype> findgoodstype = goodstypeService.findgoodstype(goodstype);
		System.out.println(findgoodstype);
		return findgoodstype;
	}
	@RequestMapping("/findsupplier")
	@ResponseBody
	public List<Supplier> findsupplier(Supplier supplier){
		System.out.println(supplier);
		List<Supplier> findsupplier = supplierService.findsupplier(supplier);
		System.out.println(findsupplier);
		return findsupplier;
	}
	@RequestMapping("/delgoodstype")
	public String delgoodstype(Integer id){
		goodstypeService.delgoodstype(id);
		return "redirect:/index.jsp";
	}
	@RequestMapping("/findgoodstypeId")
	public String findgoodstypeId(Integer id ,HttpServletRequest request){
		Goodstype findgoodsty= goodstypeService.findgoodstypeId(id);
		request.getSession().setAttribute("findgoodsty", findgoodsty);
		return "redirect:/jsp/goodstype/updategoodstype.jsp";
	}
	@RequestMapping("/updategoodstype")
	public String updategoodstype(Goodstype goodstype){
		System.out.println("---------goodstype-----------"+goodstype);
		goodstypeService.updategoodstype(goodstype);
		return "redirect:/jsp/goodstype/goodstype.jsp";
	}
	
}
